home *** CD-ROM | disk | FTP | other *** search
/ Borland JBuilder 6 / jbuilder6.iso / IBM VisualAge for Java Enterprise v4.0 Retail / ivj40 / setup / IDE.Cab / F87880_FactoryMethodSetModel.class (.txt) < prev    next >
Encoding:
Java Class File  |  2001-03-22  |  2.3 KB  |  61 lines

  1. package com.ibm.ivj.testpilot.model;
  2.  
  3. import com.ibm.ivj.testpilot.utils.ClassUtils;
  4. import java.lang.reflect.Method;
  5.  
  6. public class FactoryMethodSetModel extends MethodSetModel {
  7.    private static String copyright = "Licensed Material - Property of IBM IBM(R) VisualAge(R) for Java(TM), Version 3.5 (C) Copyright IBM Corp. 1997, 2000- All Rights Reserved. US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.";
  8.    private MethodModel[] methods = null;
  9.    private Class factoryClass = null;
  10.    private Class outputType = null;
  11.    private static final String factorySetName = ResourceHandler.getHandler().getMessage("FACTORY_METHODS");
  12.  
  13.    public FactoryMethodSetModel(MemberModel var1, Class var2, Class var3) {
  14.       super(var1, factorySetName);
  15.       this.initializeFactoryClass(var2);
  16.       this.initializeOutputType(var3);
  17.    }
  18.  
  19.    public Class getFactoryClass() {
  20.       return this.factoryClass;
  21.    }
  22.  
  23.    protected static final Method[] getFactoryMethodsFor(Class var0, Class var1) {
  24.       return ClassUtils.getPublicStaticMethods(var0, var1);
  25.    }
  26.  
  27.    public MemberModel[] getMembers() {
  28.       return this.getMethods();
  29.    }
  30.  
  31.    protected MemberModel[] getMethods() {
  32.       if (this.methods == null) {
  33.          MemberModel var1 = ((MemberModel)this).getOwner();
  34.          Method[] var2 = getFactoryMethodsFor(this.getFactoryClass(), this.getOutputType());
  35.          int var4 = var2.length;
  36.          MethodModel[] var5 = new MethodModel[var4];
  37.  
  38.          for(int var3 = 0; var3 < var4; ++var3) {
  39.             var5[var3] = new FactoryMethodModel(var1, var2[var3]);
  40.          }
  41.  
  42.          this.methods = new MethodModel[var4];
  43.          MethodSetModel.sort(var5, this.methods);
  44.       }
  45.  
  46.       return this.methods;
  47.    }
  48.  
  49.    public Class getOutputType() {
  50.       return this.outputType;
  51.    }
  52.  
  53.    private void initializeFactoryClass(Class var1) {
  54.       this.factoryClass = var1;
  55.    }
  56.  
  57.    private void initializeOutputType(Class var1) {
  58.       this.outputType = var1;
  59.    }
  60. }
  61.